package view;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;

import model.interfaces.ICaminos;
import model.laberinto.Caminos.Camino;
import model.utilidades.Vector;

public class MapGraphics implements Drawable{
	private boolean debugModeOn;
	private ICaminos caminos;
	
	// constructor
	public MapGraphics(ICaminos caminos, boolean debugMode){
		this.debugModeOn = debugMode;
		this.caminos = caminos;
	}	
	
	// draws the walls
	public void draw(Graphics g){
		if(debugModeOn){
			for (Camino camino : caminos.obtenerCaminos()){
				dibujarCamino(g,camino);
			}
		}
	}

	// draws a wall (4 testing!!!)
	public void dibujarCamino(Graphics g, Camino camino){
		Graphics2D g2 = (Graphics2D)g;
		g2.setStroke(new BasicStroke(3));
		g.setColor(new Color(255, 255, 0));

		Vector inicio = camino.obtenerPunto1();
		int inicioX = inicio.obtenerCoordenadaX();
		int inicioY = inicio.obtenerCoordenadaY();
		
		Vector fin = camino.obtenerPunto2();
		int finX = fin.obtenerCoordenadaX();
		int finY = fin.obtenerCoordenadaY();

		g2.draw(new Line2D.Float((float)inicioX,(float)inicioY, (float)finX, (float)finY));	

		
		g.setColor(new Color(0, 255, 0));
		g2.setStroke(new BasicStroke(5));
		g2.draw(new Line2D.Float((float)inicioX,(float)inicioY, (float)inicioX,(float)inicioY));	
		g2.draw(new Line2D.Float((float)finX,(float)finY, (float)finX,(float)finY));	
	}
	
	// (4 testing !!)
	public void changeState(int stateIndex) {}	
}
